Skip to content

Conversation

@ymeister
Copy link

@ymeister ymeister commented Aug 8, 2024

Built using haskell.nix (https://github.com/input-output-hk/haskell.nix), so as long you have ghc js backend installed on the system, normal cabal build should work too:


default.nix:

let deps = {
      "haskell.nix" = builtins.fetchTarball {
        url = "https://github.com/input-output-hk/haskell.nix/archive/d8c50dcaf3d3d589829ee9be9d5dba8279b8cc59.tar.gz";
        sha256 = "0a5hgryz6nszmy67yf1aks399h2aw0nj845518c4prs5c6ns1z7p";
      };
    };

    haskellNix = import deps."haskell.nix" {};

    # Import nixpkgs and pass the haskell.nix provided nixpkgsArgs
    pkgs = import
      # haskell.nix provides access to the nixpkgs pins which are used by our CI,
      # hence you will be more likely to get cache hits when using these.
      # But you can also just use your own, e.g. '<nixpkgs>'.
      haskellNix.sources.nixpkgs-unstable
      # These arguments passed to nixpkgs, include some patches and also
      # the haskell.nix functionality itself as an overlay.
      haskellNix.nixpkgsArgs;

    project = pkgs: pkgs.haskell-nix.project {
      src = ./.;

      shell.withHaddock = if pkgs.stdenv.hostPlatform.isGhcjs then false else true;

      # Specify the GHC version to use.
      compiler-nix-name = "ghc910"; # Not required for `stack.yaml` based projects.
    };

in {
  ghc = project pkgs;
  ghc-js = project pkgs.pkgsCross.ghcjs;
}

shell.nix:

let projects = import ./default.nix;
    project = projects.ghc;
in project.shellFor {
  tools = {
    cabal = "latest";
  };

  buildInputs = with project.pkgs; [
    nodejs-slim_latest
  ];

  # Sellect cross compilers to include.
  crossPlatforms = ps: with ps; [
    ghcjs # Adds support for `javascript-unknown-ghcjs-cabal build` in the shell
  ];
}

@ymeister
Copy link
Author

ymeister commented Aug 6, 2025

Closing in favor of #75.

@ymeister ymeister closed this Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants